package com.learn.design.abstractfactory.action;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

/**
 * @author xuhainan
 * @date 2023/8/1 16:30
 * @region hefei
 */
public class IIR {

    private final static Logger log = LoggerFactory.getLogger(IIR.class);

    private Map<String, String> dataMap = new ConcurrentHashMap<>();

    public String get(String key) {
        log.info("IIR获取数据 key：{}", key);
        return dataMap.get(key);
    }

    public void pain(String key, String value) {
        log.info("IIR写入数据 key：{}，value:{}", key, value);
        dataMap.put(key, value);
    }

    public void setExpire(String key, String value, long timeOut, TimeUnit timeUnit) {
        log.info("IIR写入数据 key:{},value:{},timeOut:{},timeUnit:{}", key, value, timeOut, timeUnit.toString());
        dataMap.put(key, value);
    }

    public void delete(String key) {
        log.info("IIR删除数据 key：{}", key);
        dataMap.remove(key);
    }

}
